﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Web.Security;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.PreRender += new EventHandler(_Default_PreRender);
    }

    void _Default_PreRender(object sender, EventArgs e)
    {
        this.OutputLabel.Text = Profile.LastClick.ToLocalTime().ToLongTimeString();
        this.OutputLabel.Text += "<br/>" + Profile.Hierarchy.DiffTime.TotalMinutes.ToString() + " min";
        this.OutputLabel.Text += " Version: " + Profile.MyVersion.ToString();
    }
    protected void Clickhandler(object sender, EventArgs e)
    {
        DateTime was = Profile.LastClick.ToLocalTime();
        Profile.SetClick();
        Profile.MyVersion = new Version(1, 2, 3);
        Profile.Hierarchy = new Profiling.MyProfile.A() { 
            Naam = "bla", 
            Child = new Profiling.MyProfile.A() 
                { 
                    Naam = "Bloe" 
                } ,
            DiffTime = (Profile.LastClick - was)
        };
        
    }
    protected void CountClickHandler(object sender, EventArgs e)
    {
        int profileCount = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.Authenticated).Count;
        int userCount ;
        Membership.GetAllUsers(0, 1, out userCount);
        int usersOnline = Membership.GetNumberOfUsersOnline();
        OutputLabel2.Text = String.Format("Users: {0}, Online now: {1}, Profiles: {2}", userCount, usersOnline, profileCount);
    }

    protected void CreateClickHandler(object sender, EventArgs e)
    {
        int sec = DateTime.Now.Second;
        for (int i = 0; i < 1000; i++)
        {
            string email = string.Format("user{1}{0:00000}@duynstee.com", i, sec);
            Membership.CreateUser(email, "password", email);
        }
    }
}


